package com.sms.client.ui;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DateBox;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
import com.sms.client.ServiceUtil;
import com.sms.client.utils.LoadingBox;
import com.sms.shared.ReportBean;
import com.sms.shared.SessionInfo;

public class ReportUI extends Composite {

	private String vType;

	private Long siteId;
	
	private String siteName;
	
	private String groupNo;
	
	private String inverterType;

//	private String equipmentType;

	private java.util.Date startDate;

	private java.util.Date endDate;

	private ListBox vtypeListBox;

	private DateBox dpFrom;

	private DateBox dpTo;

	private FlexTable appMenuTables;

	private FlexTable reportHeading;

	private FlexTable summaryTable;

	private FlexTable reportMainTable;
	private String sessionId;
	private String partyId;
	public ReportUI(Long siteId, String siteName,String groupNo, String vType, String output) {
		this.siteId = siteId;
		this.groupNo = groupNo;
		this.siteName = siteName;
		this.vType = "Hourly";
		//this.equipmentType = "Utility";
		VerticalPanel vp = new VerticalPanel();
		initWidget(vp);
		initComponents(vp);
	}

	public void initComponents(VerticalPanel vp) {
		SessionInfo userSessionInfo = SessionInfo.getSharedInstance();
		String roleName = (String) userSessionInfo.getSessionData(SessionInfo.SESSION_ROLENAME);
		sessionId = (String) userSessionInfo.getSessionData(SessionInfo.JSESSION_ID);
		inverterType = (String) userSessionInfo.getSessionData(SessionInfo.SESSION_INVERTERTYPE);
		partyId = (String) userSessionInfo.getSessionData(SessionInfo.SESSION_PARTYID);
		FlexTable flexTable = new FlexTable();
		flexTable.setWidth("100%");
		vp.add(flexTable);
		vp.setWidth("100%");

		vtypeListBox = new ListBox();
		vtypeListBox.addItem("Hourly");
		vtypeListBox.addItem("Daily");
		vtypeListBox.addItem("Monthly");
		vtypeListBox.addItem("Yearly");
//		if(inverterType.equalsIgnoreCase("Off-Grid With DG")){
			vtypeListBox.addItem("DC Log");
			vtypeListBox.addItem("AC Log");
			vtypeListBox.addItem("DC - AC Log");
//		}
		
		vtypeListBox.setItemSelected(0, true);
		vtypeListBox.setWidth("98%");

		appMenuTables = new FlexTable();
		Anchor excelMenu = new CMenuItem("excel", true, "Excel").getMenuItem();
		FlowPanel fExcel = new FlowPanel();
		fExcel.getElement().setId("excel");
		fExcel.add(excelMenu);
		appMenuTables.setWidget(0, 0, fExcel);
		((Anchor) fExcel.getWidget(0)).removeStyleName("active");
		
		addMenuClickHandler(excelMenu, "Excel");

		Anchor pdfMenu = new CMenuItem("pdf", false, "PDF").getMenuItem();
		FlowPanel fPdf = new FlowPanel();
		fPdf.getElement().setId("pdf");
		fPdf.add(pdfMenu);
		appMenuTables.setWidget(1, 0, fPdf);
		addMenuClickHandler(pdfMenu, "PDF");

		Anchor emailMenu = new CMenuItem("email", false, "Email").getMenuItem();
		FlowPanel fEmail = new FlowPanel();
		fEmail.getElement().setId("email");
		fEmail.add(emailMenu);
		appMenuTables.setWidget(2, 0, fEmail);
		addMenuClickHandler(emailMenu, "Email");

		reportHeading = new FlexTable();
		reportHeading.setWidth("100%");

		reportHeading.setWidget(0, 0, new HTML("Report"));
		reportHeading.getFlexCellFormatter().setWidth(0, 0, "5%");
		reportHeading.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
		reportHeading.getFlexCellFormatter().setStyleName(0, 0, "value_blue_m");
		reportHeading.setStyleName("box_header1");

		reportMainTable = new FlexTable();
//		chartMainTable.setBorderWidth(1);
		reportMainTable.setWidget(0, 0, reportHeading);
		//chartMainTable.getFlexCellFormatter().setWidth(0, 0, "96%");
		reportMainTable.setWidget(0, 1, appMenuTables);
		reportMainTable.getFlexCellFormatter().setRowSpan(0, 1, 4);
		reportMainTable.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
		reportMainTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
		//chartMainTable.getFlexCellFormatter().setWidth(0, 1, "4%");
		reportMainTable.getFlexCellFormatter().setStyleName(0, 1, "box_bg");
		reportMainTable.setWidth("100%");

		summaryTable = new FlexTable();
		summaryTable.setWidth("100%");
		summaryTable.setStyleName("box_bg");

		reportMainTable.setWidget(3, 0, summaryTable);
		reportMainTable.getFlexCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_BOTTOM);
		reportMainTable.getFlexCellFormatter().setHeight(0, 0, "5%");
		//reportMainTable.getFlexCellFormatter().setHeight(2, 0, "5%");

		final FlexTable filterTable = new FlexTable();
		// filterTable.setWidth("225px");

		filterTable.setWidget(1, 0, new HTML("Type"));
//		filterTable.getFlexCellFormatter().setWidth(1, 0, "44%");
		filterTable.setWidget(2, 0, vtypeListBox);
		final DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy");

		dpTo = new DateBox();
		dpTo.setWidth("98%");
		dpTo.getDatePicker().setStyleName("myDatePicker");
		dpTo.setFormat(new DateBox.DefaultFormat(format));

		dpFrom = new DateBox();
		dpFrom.setWidth("98%");
		dpFrom.getDatePicker().setStyleName("myDatePicker");
		dpFrom.setValue(new Date());

		dpFrom.setFormat(new DateBox.DefaultFormat(format));

		filterTable.setWidget(3, 0, new HTML("Date"));
		filterTable.setWidget(4, 0, dpFrom);

		vtypeListBox.addChangeHandler(new ChangeHandler() {

			@Override
			public void onChange(ChangeEvent event) {
				int index = vtypeListBox.getSelectedIndex();
				vType = vtypeListBox.getValue(index);
				if (vType.equalsIgnoreCase("Hourly") || vType.equalsIgnoreCase("DC Log") || vType.equalsIgnoreCase("AC Log")|| vType.equalsIgnoreCase("DC - AC Log")) {
					dpFrom = new DateBox();
					dpFrom.setWidth("98%");
					dpFrom.getDatePicker().setStyleName("myDatePicker");
					dpFrom.setValue(new Date());

					dpFrom.setFormat(new DateBox.DefaultFormat(format));

					filterTable.setWidget(3, 0, new HTML("Date"));
					filterTable.setWidget(4, 0, dpFrom);
					filterTable.getCellFormatter().setVisible(5, 0, false);
					filterTable.getCellFormatter().setVisible(6, 0, false);
				} else {
					filterTable.setWidget(3, 0, new HTML("From Date"));
					dpFrom = new DateBox();
					dpFrom.setWidth("98%");
					dpFrom.getDatePicker().setStyleName("myDatePicker");
					final DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy");
					dpFrom.setFormat(new DateBox.DefaultFormat(format));
					filterTable.setWidget(4, 0, dpFrom);
					dpTo.setValue(new Date());
					
					filterTable.getCellFormatter().setVisible(5, 0, true);
					filterTable.getCellFormatter().setVisible(6, 0, true);
				}
			}
		});

		
		
		Long mPartyId = Long.valueOf(partyId);
		if (roleName.equalsIgnoreCase("Admin"))
			mPartyId = null;
		ServiceUtil.getMeterServiceAsync().getSites(mPartyId, new AsyncCallback() {

			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onSuccess(Object result) {
				List<ArrayList> dataList = (List) result;
				List<String> locationList = new ArrayList<String>();
				if (dataList.size() > 1) {
					TreeItem rootItem = new TreeItem("Location");
					for (ArrayList list : dataList) {
						if (!locationList.contains((String) list.get(2)))
							locationList.add((String) list.get(2));
					}
					for (String location : locationList) {
						final TreeItem locationItem = new TreeItem(location);
						List<ArrayList> siteDataList = getSiteGroupNo(location, dataList);

						for (ArrayList dataValueList : siteDataList) {
							TreeItem groupNoTree = new TreeItem((String) dataValueList.get(1));
							groupNoTree.setUserObject(dataValueList);
							locationItem.addItem(groupNoTree);
						}
						rootItem.addItem(locationItem);
					}
					Tree tree = new Tree();
					tree.addItem(rootItem);
					filterTable.setWidget(0, 0, tree);
					filterTable.getFlexCellFormatter().setColSpan(0, 0, 2);
					filterTable.getFlexCellFormatter().setWidth(0, 0, "15%");
					tree.addSelectionHandler(new SelectionHandler<TreeItem>() {

						@Override
						public void onSelection(SelectionEvent<TreeItem> event) {
							if (event.getSelectedItem().getUserObject() != null) {
								ArrayList dataValueList = (ArrayList) event.getSelectedItem().getUserObject();
								siteId = (Long) dataValueList.get(0);
								groupNo = (String) dataValueList.get(1);
								siteName = (String) dataValueList.get(3);
								inverterType = (String) dataValueList.get(4);
								
								vtypeListBox.clear();
								vtypeListBox.addItem("Hourly");
								vtypeListBox.addItem("Daily");
								vtypeListBox.addItem("Monthly");
								vtypeListBox.addItem("Yearly");
//								if(inverterType.equalsIgnoreCase("Off-Grid With DG")){
									vtypeListBox.addItem("DC Log");
									vtypeListBox.addItem("AC Log");
									vtypeListBox.addItem("DC - AC Log");
//								}
								
								
								ServiceUtil.getUserLoginServiceAsync().setSessionData(groupNo, inverterType,sessionId, new AsyncCallback() {

									@Override
									public void onFailure(Throwable caught) {
										caught.printStackTrace();
									}

									@Override
									public void onSuccess(Object result) {
										if (result == null)
											return;
										Map resultMap = (Map) result;
										SessionInfo mUserSessionInfo = (SessionInfo) resultMap.get("result");
										SessionInfo.setUserSessionInfo(mUserSessionInfo);
										
										populateReportData();
										populateSummary();
									}
								});
							}
						}
					});
				}

			}
		});

		filterTable.setWidget(5, 0, new HTML("To Date"));
		filterTable.setWidget(6, 0, dpTo);
		filterTable.getCellFormatter().setVisible(5, 0, false);
		filterTable.getCellFormatter().setVisible(6, 0, false);
		Button goButton = new Button("Go");
		goButton.setStyleName("btn-blue");
		filterTable.setWidget(7, 0, goButton);

		goButton.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				
				populateReportData();
				populateSummary();
			}
		});

		filterTable.getFlexCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);

		flexTable.setWidget(0, 0, filterTable);
		flexTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
		populateReportData();
		populateSummary();
		//populateGaugeData();
		//refreshPage();
		flexTable.getFlexCellFormatter().setWidth(0, 0, "20%");
		flexTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
		flexTable.setWidget(0, 1, reportMainTable);
		flexTable.getFlexCellFormatter().setWidth(0, 1, "80%");

	}



	private List getSiteGroupNo(String location, List<ArrayList> siteList) {
		List dataList = new ArrayList();
		for (ArrayList list : siteList) {
			if (((String) list.get(2)).equalsIgnoreCase(location)) {
				dataList.add(list);
			}

		}
		return dataList;
	}

	private void addMenuClickHandler(final Anchor anchor, final String menuName) {
		anchor.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				int rCount = appMenuTables.getRowCount();
				for (int index = 0; index < rCount; index++) {
					FlowPanel flowPanel = (FlowPanel) appMenuTables.getWidget(index, 0);
					if (((Anchor) flowPanel.getWidget(0)).getText().equalsIgnoreCase(menuName))
						((Anchor) flowPanel.getWidget(0)).setStyleName("active");
					else
						((Anchor) flowPanel.getWidget(0)).removeStyleName("active");
				}
				final boolean isDGConfigured = inverterType.equalsIgnoreCase("Off-Grid With DG") ? true : false;
				final ReportBean reportBean = new ReportBean();
				reportBean.setStartDate(startDate);
				reportBean.setEndDate(endDate);
				reportBean.setDisplayGroupNo(groupNo);
				reportBean.setSiteId(siteId);
				reportBean.setDocType(menuName);
				reportBean.setvType(vType);
				reportBean.setDGConfigured(isDGConfigured);
				
				ServiceUtil.getMeterServiceAsync().generateReportToken(reportBean, new AsyncCallback() {

					@Override
					public void onFailure(Throwable caught) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public void onSuccess(Object result) {
						String token = (String)result;
						if(token != null && token.trim().length() > 0){
							
							String filename = reportBean.getDisplayGroupNo().replaceAll("\\s+","").replaceAll("-", "_")+"_"+reportBean.getvType().replaceAll("\\s+","").replaceAll("-", "_");
							System.err.println("GWT.getModuleBaseURL()."+GWT.getModuleBaseURL());
							Window.open(GWT.getModuleBaseURL()+"DocReport?token=" + token+"&docType="+menuName+"&fileName="+filename, "_blank", "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");
						}
						
					}
				});
				//equipmentType = menuName;
				//populateChartData();
				//populateGaugeData();

			}
		});
	}

	private void populateReportData() {
		final boolean isDGConfigured = inverterType.equalsIgnoreCase("Off-Grid With DG") ? true : false;
		startDate = dpFrom.getValue();
		
//		if(!isDGConfigured){
//			if(vType.equalsIgnoreCase("DC Log") || vType.equalsIgnoreCase("AC Log")){
//				Window.alert("Please choose another type");
//				return;
//			}
//		}
		
		if (vType.equalsIgnoreCase("Hourly") || vType.equalsIgnoreCase("DC Log") || vType.equalsIgnoreCase("AC Log")|| vType.equalsIgnoreCase("DC - AC Log")) {
			endDate = null;
			if (startDate == null) {
				Window.alert("Please choose the date");
				return;
			}
		} else {
			endDate = dpTo.getValue();
			if (startDate == null || endDate == null) {
				Window.alert("Please choose the from/to date");
				return;
			}
		}

		LoadingBox.getSharedInstance().show();
		String dateRange = "";
		if (vType.equalsIgnoreCase("Hourly") || vType.equalsIgnoreCase("DC Log") || vType.equalsIgnoreCase("AC Log") || vType.equalsIgnoreCase("DC - AC Log"))
			dateRange = dateRange + DateTimeFormat.getFormat("dd/MM/yyyy").format(startDate);
		else {
			dateRange = dateRange + DateTimeFormat.getFormat("dd/MM/yyyy").format(startDate);
			dateRange = dateRange + " - ";
			dateRange = dateRange + DateTimeFormat.getFormat("dd/MM/yyyy").format(endDate);
		}

		reportHeading.setWidget(0, 1, new HTML(siteName));
		
		reportHeading.setWidget(0, 2, new HTML("("+groupNo+")"));
		reportHeading.getFlexCellFormatter().setWidth(0, 1, "32%");
		reportHeading.getFlexCellFormatter().setWidth(0, 2, "31%");
		reportHeading.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
		reportHeading.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_LEFT);
		reportHeading.getFlexCellFormatter().setStyleName(0, 1, "value_blue_s");
		reportHeading.getFlexCellFormatter().setStyleName(0, 2, "body_txt_black_b");
		

		HTML dateHtml = new HTML("<span class=\"value_blue_s\">" + vType + "</span><span class=\"body_txt_black_b\"> (" + dateRange + ")</span>");
		reportHeading.setWidget(0, 3, dateHtml);
		reportHeading.getFlexCellFormatter().setWidth(0, 3, "32%");
		reportHeading.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
		ServiceUtil.getMeterServiceAsync().getReportData(siteId, groupNo, vType, startDate, endDate,isDGConfigured, new AsyncCallback<List<ArrayList>>() {

			@Override
			public void onFailure(Throwable caught) {
				LoadingBox.getSharedInstance().hide();
				
			}

			@Override
			public void onSuccess(final List<ArrayList> result) {
				LoadingBox.getSharedInstance().hide();
				reportMainTable.setWidget(1, 0, new HTML());
			    reportMainTable.setWidget(2, 0, new HTML());
				final List<String> headingList = result.get(0);
				result.remove(0);
				//recordIndex = 0;
				CellTable<ArrayList> table = new CellTable<ArrayList>();
				int columnIndex = 0;
				for(String heading : headingList){
					addHeader(table, heading, columnIndex);
					columnIndex++;
				}
//				ListDataProvider<ArrayList> dataProvider = new ListDataProvider<ArrayList>();
//
//				dataProvider.addDataDisplay(table);
//
//				List<ArrayList> list = dataProvider.getList();
//				for (ArrayList arrayList : result) {
//					list.add(arrayList);
//				}
				
			    AsyncDataProvider<ArrayList> provider = new AsyncDataProvider<ArrayList>() {
			        @Override
			        protected void onRangeChanged(HasData<ArrayList> display) {
			          int start = display.getVisibleRange().getStart();
			          int end = start + display.getVisibleRange().getLength();
			          end = end >= result.size() ? result.size() : end;
			          List<ArrayList> sub = result.subList(start, end);
			          updateRowData(start, sub);
			        }
			      };
			      provider.addDataDisplay(table);
			      provider.updateRowCount(result.size(), true);

			      SimplePager pager = new SimplePager();
			      pager.setDisplay(table);
			      pager.setPageSize(10);
			      reportMainTable.setWidget(1, 0, table);
			      reportMainTable.setWidget(2, 0, pager);
			}
		});

	}
	
	private void addHeader(CellTable<ArrayList> table,String heading, final int index){
		TextColumn<ArrayList> textColumn = new TextColumn<ArrayList>() {
			@Override
			public String getValue(ArrayList arrayList) {
				if (arrayList.get(index) instanceof String)
					return (String) arrayList.get(index);
				else
					return String.valueOf((Double) arrayList.get(index));
			}
		};
		table.addColumn(textColumn, heading);
	}

	private void populateSummary() {
		LoadingBox.getSharedInstance().show();
		final boolean isDGConfigured = inverterType.equalsIgnoreCase("Off-Grid With DG") ? true : false;
		ServiceUtil.getMeterServiceAsync().getSummaryData(siteId,groupNo ,isDGConfigured, new AsyncCallback() {

			@Override
			public void onFailure(Throwable caught) {
				LoadingBox.getSharedInstance().hide();
				
			}

			@Override
			public void onSuccess(Object result) {
				LoadingBox.getSharedInstance().hide();
				Map dataMap = (Map)result;
				Set set = dataMap.entrySet();
				Iterator i = set.iterator();
				int columnIndex = 0;
				while (i.hasNext()) {
					Map.Entry me = (Map.Entry) i.next();
					String key = (me.getKey() instanceof String) ? (String) me.getKey() : String.valueOf(me.getKey());
					if (me.getValue() != null) {
						ArrayList dataValueList = (ArrayList) me.getValue();
						getSummaryTable(key, dataValueList, columnIndex);
						columnIndex++;
					}
				}
				
			}
		});
	}

    private void getSummaryTable(String title,List dataValueList,int columnIndex){
    	FlexTable headingTable = new FlexTable();
    	headingTable.setWidget(0, 0, new HTML(title));
		//reportHeading.getFlexCellFormatter().setWidth(0, 0, "5%");
    	headingTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
    	headingTable.getFlexCellFormatter().setStyleName(0, 0, "value_blue_m");
    	headingTable.setStyleName("box_header1");
    	headingTable.setWidth("100%");
    	
    	summaryTable.setWidget(0, columnIndex, headingTable);
    	summaryTable.getFlexCellFormatter().setWidth(0, columnIndex, "25%");
    	
    	FlexTable valueTable = new FlexTable();
    	valueTable.setWidth("100%");
    	valueTable.getFlexCellFormatter().setWidth(0, 0, "60%");
    	valueTable.getFlexCellFormatter().setWidth(0, 1, "40%");
    	
    	valueTable.getFlexCellFormatter().setStyleName(0, 0, "body_txt_blue2_b");
    	valueTable.getFlexCellFormatter().setStyleName(0, 1, "body_txt_black_b");
    	valueTable.getFlexCellFormatter().setStyleName(1, 0, "body_txt_blue2_b");
    	valueTable.getFlexCellFormatter().setStyleName(1, 1, "body_txt_black_b");
    	valueTable.getFlexCellFormatter().setStyleName(2, 0, "body_txt_blue2_b");
    	valueTable.getFlexCellFormatter().setStyleName(2, 1, "body_txt_black_b");
    	valueTable.setWidget(0, 0, new HTML("Solar Generation"));
    	valueTable.setWidget(0, 1, new HTML((Double)dataValueList.get(0)+" Kwh"));
    	
    	valueTable.setWidget(1, 0, new HTML("Facility Consumption"));
    	valueTable.setWidget(1, 1, new HTML((Double)dataValueList.get(1)+" Kwh"));
    	
    	valueTable.setWidget(2, 0, new HTML("Grid Consumption"));
    	valueTable.setWidget(2, 1, new HTML((Double)dataValueList.get(2)+" Kwh"));
		if (inverterType.equalsIgnoreCase("Off-Grid With DG")) {
			valueTable.setWidget(3, 0, new HTML("DG Generation"));
			if(dataValueList.size() > 3)
				valueTable.setWidget(3, 1, new HTML((Double) dataValueList.get(3) + " Kwh"));
			else
				valueTable.setWidget(3, 1, new HTML("0.0 Kwh"));
			valueTable.getFlexCellFormatter().setStyleName(3, 0, "body_txt_blue2_b");
			valueTable.getFlexCellFormatter().setStyleName(3, 1, "body_txt_black_b");
		}
    	
    	summaryTable.setWidget(1, columnIndex, valueTable);
    }

	public static native int getScreenWidth() /*-{
		return $wnd.screen.width;
	}-*/;

	public static native int getScreenHeight() /*-{
		return $wnd.screen.height;
	}-*/;

}
